package com.xy.webadmin;

import com.alibaba.druid.stat.DruidDataSourceStatManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 应用服务启动类。
 *
 * @author xiaoyue
 * @date 2025-05-13
 */
@EnableAsync
@SpringBootApplication
@ComponentScan("com.xy")
@EnableScheduling
public class WebAdminApplication {


    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(WebAdminApplication.class, args);
        
        // 添加关闭钩子，在应用关闭时清理Druid资源
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            try {
                // 清理Druid的资源
                DruidDataSourceStatManager.clear();
            } catch (Exception e) {
                // 忽略清理过程中的异常
            }
        }));
    }


}
